<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>   
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文章管理</title>
    <meta name="keywords" content="用户管理">
    <meta name="description" content="用户管理">
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/Public/Admin/css/bootstrap.min.css" rel="stylesheet">
    <link href="/Public/Admin/css/font-awesome.min.css" rel="stylesheet">
    <link href="/Public/Admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/Public/Admin/css/animate.css" rel="stylesheet">
    <link href="/Public/Admin/css/style.css" rel="stylesheet">
    <link href="/Public/Admin/js/plugins/layer/skin/default/layer.css" rel="stylesheet">
    <link href="/Public/Admin/js/plugins/layer/laypage/skin/laypage.css" rel="stylesheet">
    <link href="/Public/Admin/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <style>
    #show img{width:60px; height: 60px; border-radius: 50%; box-shadow: 0 0 5px 1px #999;}
    .h10{height: 20px; }
    .modal-header{background: #3BB3A8; color: #fff;}
    #submit{ margin-right: 10px;}
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>文章管理</h5>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-sm-4">
                            <div class="input-group">
                                <a href="<?php echo U('Article/add');?>" class="btn btn-outline btn-primary ">添加文章</a>
                            </div>
                        </div>
                        <form name="art_list" id="art_list" action="<?php echo U('index');?>" method="get">
                            <div class="col-sm-5">
                                <div class="input-group">
                                    <input type="text" placeholder="请输入关键词" class="input-sm form-control" name="title" id="title" value="<?php echo ($title); ?>"> <span class="input-group-btn">
                                    <button type="submit" id="submit" class="btn btn-sm btn-primary"> 搜索</button> </span>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="hr-line-dashed" style="margin: 10px"></div>
                    <div class="table-responsive">
                        <table class="table table-bordered">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>文章栏目</th>
                                <th>文章名称</th>
                                <th>文章作者</th>
                                <th>文章图片</th>
                                <th>seo关键词</th>
                                <th>seo描述</th>
                                <th>文章内容</th>
                                <th>添加时间</th>
                                <th>是否生成静态</th>
                                <th>添加人</th>
                                <th>点击次数</th>
                                <th>排序</th>
                                <th width="10%">操作</th>
                            </tr>
                            </thead>
                            <tbody id="show">

                                <!-- tp用volist俩循环输出从数据库读出的内容 -->
                                <?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vs): $mod = ($i % 2 );++$i;?><tr>
                                        <td><?php echo ($vs["id"]); ?></td>
                                        <td><?php echo ($vs["coltitle"]); ?></td>
                                        <td><?php echo (mb_substr($vs["title"], 0,5,"utf-8")); ?></td>
                                        
                                        <td><?php echo ($vs["author"]); ?></td>
                                        <td><a href="<?php echo U('Article/upload?id='.$vs['id']);?>">查看图片</a></td>
                                        <td><?php echo (mb_substr($vs["seo_keywords"], 0,10,"utf-8")); ?></td>
                                        <td><?php echo (mb_substr($vs["seo_description"], 0,10,"utf-8")); ?></td>
                                        <td><?php echo (mb_substr(strip_tags(htmlspecialchars_decode($vs["content"])), 0,10,"utf-8")); ?></td>
                                        <td><?php echo ($vs["addtime"]); ?></td>
                                        <td>    
                                            <?php if($vs['is_html'] == 1): ?>静态
                                            <?php else: ?>
                                            动态<?php endif; ?>
                                        </td>
                                        <td><?php echo ($vs["addman"]); ?></td>
                                        <td><?php echo ($vs["hits"]); ?></td>
                                        <td><?php echo ($vs["sort"]); ?></td>
                                        <td>
                                            <a href="<?php echo U('Article/edit?id='.$vs['id']);?>" class="label label-primary"><i class="fa fa-edit"></i> 修改</a>
                                            &nbsp;&nbsp;&nbsp;&nbsp;
                                            <a href="javascript:del(<?php echo ($vs["id"]); ?>);" class="label label-danger"><i class="fa fa-trash"></i> 删除</a>
                                        </td>
                                    </tr><?php endforeach; endif; else: echo "" ;endif; ?>
                                </tbody>
                        	</table>                        
                        	<div id="pages" class="page" style="text-align: center"></div>
                    </div>
                 
                </div>
            </div>
        </div>

    </div>
</div>
<script src="/Public/Admin/js/jquery.min.js"></script>
<script src="/Public/Admin/js/bootstrap.min.js"></script>
<script src="/Public/Admin/js/plugins/layer/layer.js"></script>
<script src="/Public/Admin/js/plugins/layer/laypage/laypage.js"></script>
<script src="/Public/Admin/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="/Public/Admin/js/comment.js"></script>
<script>
function del(id){
    swal({   
        title: "主人确定要舍弃奴家吗？",  
        text: "",   
        type: "warning",   
        showCancelButton:true,   
        confirmButtonColor: "#ec6c62",   
        confirmButtonText: "果断舍弃！",   
        cancelButtonText: "让我想想！",   
        closeOnConfirm: false  
    },function(){   
        $.post("<?php echo U('Article/del');?>",{id:id},function(data){
                if(data.status < 1){
                    swal({title:"很遗憾", text:data.mess, type:"error"});
                }else{
                    swal({title:"成功", text:data.mess, type:"success"},function(){
                       window.location.reload();//刷新页面 
                    });
                }
            },'json');
    });
}

    var title = '<?php echo ($title); ?>';
    laypage({
          cont:'pages',//容器就是div定义的id
          pages: <?php echo ($page); ?>, //可以叫服务端把总页数放在某一个隐藏域，再获取， 从后台获取的总页码数
          skin: '#009688',
          skip: true, //是否开启跳页
          curr: function(){ //通过url获取当前页，也可以同上（pages）方式获取
            var page = location.search.match(/page=(\d+)/);//获取当前页（地址栏中获取的有参数page）到后台的$page
            return page ? page[1] : 1;
          }(), 
          //点击跳转时出发回调函数first是形参不是第一页的话就是跳转到点击的页面
          jump: function(e, first){ //触发分页后的回调
            if(!first){ //一定要加此判断，否则初始时会无限刷新
              location.href = '?title='+ title +'&page='+e.curr;//e是返回的很多参数只选取当前页的参数
            }
          }
    });


</script>
</body>
</html>